package com.todo.user.application.frontend.controller;

import com.todo.common.common.entity.response.BizResponse;
import com.todo.user.application.frontend.service.UserInfoAggService;
import com.todo.user.iface.frontend.UserInfoFrontendIface;
import com.todo.user.iface.frontend.request.QueryUserDetailParam;
import com.todo.user.iface.frontend.request.UserDetailParam;
import com.todo.user.iface.frontend.request.UserHeadImgParam;
import com.todo.user.iface.frontend.response.UserDetailVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zhangwenxiang
 * @date 2024/4/9 10:24
 * @description
 */
@RestController
@RequestMapping("/userInfo")
@Tag(name = "用户前台接口", description = "用户前台接口")
public class UserInfoFrontendController implements UserInfoFrontendIface {

    @Resource
    private UserInfoAggService userInfoAggService;


    @Override
    @Operation(summary = "查询用户详情")
    @PostMapping("/queryUserDetail")
    public BizResponse<UserDetailVO> queryUserDetail(@RequestBody QueryUserDetailParam param) {
        if (param == null) {
            return BizResponse.paramError("参数异常");
        }
        return userInfoAggService.queryUserDetail(param);
    }

    @Override
    @Operation(summary = "更新用户详情")
    @PostMapping("/updateUserDetail")
    public BizResponse<Boolean> updateUserDetail(@RequestBody UserDetailParam param) {
        if (param == null) {
            return BizResponse.paramError("参数异常");
        }
        return userInfoAggService.updateUserDetail(param);
    }

    @Override
    @Operation(summary = "更新用户头像")
    @PostMapping("/updateUserHeadImg")
    public BizResponse<Boolean> updateUserHeadImg(UserHeadImgParam param) {
        if (param == null) {
            return BizResponse.paramError("参数异常");
        }
        return userInfoAggService.updateUserHeadImg(param);
    }

}
